package org.ourgrid.broker.scheduler.workqueue;

import java.util.ArrayList;
import java.util.List;

import org.ourgrid.broker.commands.SchedulerData;

public class SchedulerDataCollector {
	
	private static SchedulerDataCollector instance;
	private List<SchedulerData> dataList;
	
	private SchedulerDataCollector() {
		this.dataList = new ArrayList<SchedulerData>();
	}
	
	public static SchedulerDataCollector getInstance() {
		if (instance == null) {
			instance = new SchedulerDataCollector();
		}
		return instance;
	}
	
	public List<SchedulerData> getData() {
		List<SchedulerData> newList = new ArrayList<SchedulerData>();
		newList.addAll(this.dataList);
		this.dataList.clear();
		return newList;
	}
	
	public void addData(SchedulerData... schedulerData) {
		for (SchedulerData data : schedulerData) {
			this.dataList.add(data);
		}
	}
	
	
}
